package com.yhao.stock.controller;


import com.yhao.stock.common.service.SHService;
import com.yhao.stock.common.utils.DateUtil;
import com.yhao.stock.entity.StockInfo;
import com.yhao.stock.service.StockInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 历史交易数据 前端控制器
 * </p>
 *
 * @author yhao
 * @since 2023-11-15
 */
@RestController
@RequestMapping("/hisData2023")
public class HisData2023Controller {

    @Autowired
    private SHService shService;

    @GetMapping("/getAllHisInfos")
    public String getAllHisInfos() {
        final List<StockInfo> list = new ArrayList<>();
        StockInfo stockInfo1 = new StockInfo("603706", "东方环宇");
        StockInfo stockInfo2 = new StockInfo("603929", "亚翔集成");
        list.add(stockInfo1);
        list.add(stockInfo2);
        String code = "";
        String name = "";
        String startDate = "20231113";
        String endDate = DateUtil.getDate("yyyyMMdd");
        // String endDate = "20231113";
        for (StockInfo stockInfo : list) {
            code = stockInfo.getdCode();
            name = stockInfo.getdName();
            shService.getHisInfoByYear(code, name, startDate, endDate);
        }
        return "success";
    }
}
